package com.yupi.yupao.config;

import com.yupi.yupao.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: Peter
 * @Date: 2024-02-17-15:05
 * @Description: Pe
 */
/**
 * @author zry
 * @create 2022-04-09 17:31
 */

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    /**
     * 注册自定义拦截器
     * @param registry ·
     */
    @Resource
    private UserLoginInterceptor userLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/user/**","/team/**","/ws/**") // 拦截地址
                .excludePathPatterns("/doc.html/**",
                        "/swagger-resources/**",
                        "/**/v2/api-docs" ,"/webjars/**")
                .excludePathPatterns("/user/wxLogin","/user/recommend","/team/list/page","/team/policy");

    }
    /**
     * 设置静态资源映射
     * @param registry
     */
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/");
        registry.addResourceHandler("doc.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");


    }
}


